import 'package:appflutterhomeschool/provider/provider_widget.dart';
import 'package:appflutterhomeschool/res/index.dart';
import 'package:appflutterhomeschool/ui/widgets/general_page_jump_widget.dart';
import 'package:appflutterhomeschool/ui/widgets/widgets.dart';
import 'package:appflutterhomeschool/view_model/my/my_view_model.dart';
import 'package:appflutterhomeschool/view_model/my_app_view_model.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

///用户：Nine Tailed Fox
///时间：2020/6/8
///邮箱：1037438704@qq.com
///功能：我的页面

class MyPage extends StatefulWidget {
  @override
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> with AutomaticKeepAliveClientMixin {

  @override
  bool get wantKeepAlive => true;


  @override
  // ignore: must_call_super
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colours.gray_f6,
      body: ProviderWidget<MyViewModel>(
        model: MyViewModel(context),
        onModelReady: (value) {
          value.initView();
          value.initData();
        },
        builder: (me, viewModel, childe) {
          MyAppViewModel  myAppViewModel = Provider.of<MyAppViewModel>(me);
          myAppViewModel.myViewModel = viewModel;
          return Column(
            children: <Widget>[
              UserInformationWidget(
                clsNum: viewModel.clsNum,
                userName: viewModel.nameTitle,
                image: viewModel.imageUrl,
                identity: viewModel.titleIdentity,
              ),
              GeneralPageJumpWidget(
                image: viewModel.imageInformation,
                title: viewModel.titleInformation,
                onTap: () => viewModel.initEvent(0),
              ),
              SizedBox(height: 10),
             Visibility(
               visible: false,
               child:  GeneralPageJumpWidget(
                 image: viewModel.imageResourceBase,
                 title: viewModel.titleResourceBase,
                 onTap: () => viewModel.initEvent(1),
               ),
             ),
              GeneralPageJumpWidget(
                  image: "geren_qiehuan",
                  title: "切换身份",
                  rightContent: viewModel.identity ? "我是老师" : "我是家长",
                  onTap: () => viewModel.initEvent(2)),
              SizedBox(height: 10),
              GeneralPageJumpWidget(
                image: "geren_kefu",
                title: "客服/帮助",
                onTap: () => viewModel.initEvent(3),
              ),
              SizedBox(height: 1),
              GeneralPageJumpWidget(
                image: "geren_shezhi",
                title: "设置",
                onTap: () => viewModel.initEvent(4),
              ),
              SizedBox(height: 10),
              GeneralPageJumpWidget(
                image: "geren_tuichu",
                title: "退出登录",
                onTap: () => viewModel.initEvent(5),
              ),
            ],
          );
        },
      ),
    );
  }


}
